home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12607 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: rain.fr!world-net!cancer
  2. From: zoccolo@worldnet.fr (Franck ZOCCOLO)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Casting pointer to member function to pointer to function
  5. Date: Wed, 20 Mar 96 20:59:14 GMT
  6. Organization: Association des Joueurs de Baby-Foot (A.J.B.F)
  7. Message-ID: <4iprqv$onv@aldebaran.sct.fr>
  8. References: <314CD34A.7DBB@world.std.com>
  9. NNTP-Posting-Host: nice0-133.sct.fr
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Newsreader: News Xpress 2.0 Beta #0
  14.  
  15. >|Hi all,
  16. >|
  17. >|I can't seem to get this to work and can't figure if it's even legal.  I 
  18. >|have a global function that takes as an argument a pointer to function. 
  19. >|The pointer to function is defined as 
  20. >|
  21. >|long (__stdcall *)(void *,unsigned int,unsigned int,long)
  22. >|
  23. >|I would like to pass a function that is a member of a class called CGWnd 
  24. >|to this function which would be defined as:
  25. >|
  26. >|long (__stdcall CGWnd::*)(void *,unsigned int,unsigned int,long)
  27. >|
  28. >|I've tried casting but but MSVC++ gives me an error that effectively 
  29. >|says I can't cast away the function's class membership.  Anyone know if 
  30. >|there is a way around this?
  31. >|
  32.  
  33. A member function has an hidden parameter (named "this"). 
  34. So you can't convert  a member function pointer to a "classic" function 
  35. pointer. If you want to do that anyway, you should (I don't know if it works) 
  36. declare your member function as a static member in your class.
  37.  
  38. |
  39.  
  40. Franck ZOCCOLO
  41. Computer Science Student
  42. E-Mail: zoccolo@essi.fr              / zoccolo@worldnet.fr
  43. WWW   : http://www.essi.fr/~zoccolo /  http://www.worldnet.fr/~zoccolo
  44.